# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=aom
pkgver=1.0.0
pkgrel=1
pkgdesc="Alliance for Open Media (AOM) AV1 codec SDK"
url="https://aomedia.org/"
arch="all"
license="custom"
options="!check" # No test suite from upstream
makedepends="cmake perl python3 yasm"
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://aomedia.googlesource.com/aom/+archive/v$pkgver-errata1-avif.tar.gz"

case "$CARCH" in
	ppc64le) makedepends="$makedepends linux-headers" ;;
esac

build() {
	mkdir -p aom_build
	cd aom_build
	local _neon_opt=
	case "$CARCH" in
		arm*) _neon_opt="-DENABLE_NEON=OFF";;
	esac

	cmake .. \
		$_neon_opt \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS"

	make
}

package() {
	cd aom_build

	make DESTDIR="$pkgdir" install

	cd "$builddir"
	install -Dm 644 -t "$pkgdir"/usr/share/doc/"$pkgname"/ README.md
	install -Dm 644 -t "$pkgdir"/usr/share/doc/"$pkgname"/ LICENSE
	install -Dm 644 -t "$pkgdir"/usr/share/doc/"$pkgname"/ PATENTS
}

unpack() {
	mkdir -p "$builddir"
	cd "$builddir"

	busybox tar -zxvf "$srcdir/$pkgname-$pkgver.tar.gz" \
		-C "$builddir" > /dev/null
}

sha512sums="ea5226a72c048ee460ee798083990cbed91341875bb2998263d67078c3317efbe523f71d6b8dae420cf6691216befa9117f73a90132b4f5b09ed0f470f658e06  aom-1.0.0.tar.gz"
